package me.hl.javaslang;


import javaslang.control.Try;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static javaslang.API.*;
import static javaslang.Patterns.Failure;
import static javaslang.Patterns.Success;

/**
 * Created by yy on 2016/8/3.
 */
public class MatchTest {

    private static Logger logger = LoggerFactory.getLogger(MatchTest.class);

    @Test
    public void testMatch() {
        Try<Integer> ans = Try.of(() -> 1 / 1);
        Integer a = Match(ans).of(
                Case(Success($()), value -> ans.get()),
                Case(Failure($()), value -> -1)
        );
        logger.info("ans = {}", a);
    }
}
